
layui.use('table', function() {
	var table = layui.table;
	
	layer.msg('数据加载中...', {
		icon: 16,
		shade: 0.3,
		success: function() {
			$.ajax({
				type: 'post',
				dataType: 'json',
				url: listSrc,
				success: function(data) {
					
					table.render({
						elem: '#centet-cen',
						height: $(".center-tab").height(),
						id:'idTest',
						cols: [
							[ //标题栏
								{
									field: 'id',
									title: 'ID',
									width: 60
								}, {
									field: 'mid',
									title: '用户编号',
									width: 100
								}, {
									field: 'content',
									title: '内容',
									minWidth: 300
								}, {
									field: 'create_date',
									title: '发起时间',
									width: 200
								}, {
									field: 'post_time',
									title: '回复时间',
									width: 200
								}, {
									field: 'oper',
									title: '操作',
									width: 200,
									toolbar: '#barDemo'
								}

							]
						],
						data: data.data,
						limit: 200
					});
					var pageHtml = data.page_html;
					$(".paging").html(pageHtml);
					layer.close(layer.index);
				}
			});
		}
	})
	
	
	table.on('tool(table)', function(obj) {
    	var data = obj.data;
    	if(obj.event === 'edit') {
    		var id = data.id;
    		window.location.href = ''+xqSrc+'?id='+id+'';
    	}else if(obj.event === 'del'){
    		var id = data.id;
    		layer.alert('您确定关闭工单！',{
				icon: 2,
				btn: ['确定', '关闭'],
				btn1: function(){
					$.ajax({
				    	type:'post',
				    	dataType:'json',
				    	url:gbSrc,
				    	data:{
				    		token:token,
				    		id:id
				    	},
				    	success:function(data){
				    		var code=data.code;
				    		var msg=data.msg;
				    		if(code==1){
				    			layer.close(layer.index)
				    			layer.alert(msg,{icon: 1},function(){
				    				location.reload();
				    			})
				    		}else{
				    			layer.close(layer.index)
				    			layer.alert(msg,{icon: 5})
				    		}
				    	}
				    })
				}
			})
    	}
    	
    	
    })
	

})